<template>
	<ve-dialog
		width="510px"
		title="操作日志"
		:show.sync="isShow"
		:on-close="onCloseDialog"
	>
		<div class="log-wrapper" v-loading="isLoading">
			<div class="log-list" v-if="logList.length">
				<div class="log-line" />
				<el-timeline>
					<el-timeline-item
						v-for="(log, index) in logList"
						:key="index"
					>
						<div class="log-item">
							<p class="log-info time">操作时间： {{ log.operationTime }}</p>
							<div class="log-line" />
							<p class="log-info">操作人： {{ log.operationName }}</p>
							<p class="log-info">操作内容： {{ log.operationContext }}</p>
						</div>
					</el-timeline-item>
				</el-timeline>
			</div>
			<div class="no-data" v-if="!logList.length && finished">
				暂无数据
			</div>
		</div>
	</ve-dialog>
</template>
<script>
import coursewareApi from "@rc/apis/rc/courseware.mjs";
export default {
    props:{
        isShow: {
            type: Boolean,
            default: false
        },
        resourceId: {
            type: String,
            required: true
        }
    },
    watch: {
		isShow(val) {
			val && this.queryOperationLogs();
		}
	},
    data() {
      return {
          /* 加载中*/
          isLoading: false,
          finished: false,
          logList: []
      };
    },
    methods: {
        queryOperationLogs() {
            this.finished = false;
            this.isLoading = true;
            coursewareApi.queryOperationLogs({
                data: {
                    resourceId: this.resourceId,
                },
                success: (data) => {
                    this.logList = data;
                },
                complete: () => {
                    this.finished = true;
                    this.isLoading = false;
                }
            });
        },
        /**
         * @description 关闭弹窗
         */
        onCloseDialog() {
            this.finished = false;
            this.isLoading = false;
            this.logList = [];
            this.$emit('close');
        }
    }
  };

</script>
<style lang="less" scoped>
    .log-wrapper{
        overflow-y: scroll;
        min-height: 300px;
        max-height: 639px;

        .log-list{
        .log-line{
            width: 100%;
            box-sizing: border-box;
            height: 1px;
            border-top: 1px dashed #f0f0f0;
            margin-bottom: 10px;
        }

         /deep/ .el-timeline-item__tail{
            left: 9px;
            border-left: 1px dashed #f0f0f0;
        }
        /deep/ .el-timeline-item__node{
            width: 18px;
            height: 18px;
            background: #e7f3ff;
            border-radius: 50%;
             &::before{
                position: absolute;
                content: '';
                width: 8px;
                height: 8px;
                background: #1890ff;
                border-radius: 50%;
                top: 5px;
                left: 5px;
                z-index: 10;
            }
        }
        .log-item{
            box-sizing: border-box;
            padding: 16px;
            background: #fbfbfb;
            border-radius: 4px;
            .log-info{
                font-size: 14px;
                text-align: left;
                color: #535766;
                line-height: 19px;
                margin-bottom: 10px;
                &.time{
                    font-weight: bold;
                    color: #3A3D4B;
                }
            }
        }
        }
        .no-data {
            font-size: 14px;
            color: #909399;
            line-height: 19px;
            text-align: center;
        }
    }


</style>
